#pragma once
#include<iostream>
#include<functional>
#include<vector>
#include<stdlib.h>
void DownLoad()
{
    std::cout<<"执行下载任务..."<<"\n";
}

void UpLoad()
{
    std::cout<<"执行上传任务..."<<"\n";
}

void Music()
{
    std::cout<<"执行音乐任务..."<<"\n";
}

using task_t = std::function<void()>;
class Task
{
    private:
    std::vector<task_t> tasks;
    public:
    Task()
    {
        tasks.push_back(DownLoad);
        tasks.push_back(UpLoad);
        tasks.push_back(Music);
    }
    int select_task()//随机选择一个任务码
    {
        int pos=rand();
        pos%=tasks.size();
        return pos;
    }
    void run_task(int pos)//执行指定任务码
    {
        if(pos>=0&&pos<tasks.size())
        tasks[pos]();
    }  
};
Task _t;